<template>
  <div v-loading="loading" class="list-table" style="height: 80vh">
    <barLineChart v-if="chartData.datas.length > 0" :chart-data="chartData" height="100%" />
  </div>
</template>

<script>
import { getBarChart } from '@/api/deal/cashflow/dealCashflowForcecast'
import barLineChart from '@/views/chart/barLineChart.vue'
export default {
  components: { barLineChart },
  data() {
    return {
      loading: false,
      chartData: {
        datas: []
      }
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      this.loading = true
      getBarChart({}).then(res => {
        if (res.code === 200) {
          this.chartData.xLabel = res.data.legend || []
          this.chartData.datas = res.data.data || []
          this.chartData.legend = true
          this.chartData.legendLeft = 'center'
          this.chartData.yAxisName1 = this.$t('金额单位')
          this.chartData.rotate = 35
          this.chartData.datas.forEach(v => {
            v.type = 'bar'
            v.name = v.legend
          })
          this.loading = false
        }
      })
     }
  }
}
</script>

<style scoped>

</style>
